home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / bindings / fun / delchar < prev    next >
Encoding:
Text File  |  1996-09-27  |  4.7 KB  |  145 lines

  1. @if-using not(ocl-file-delchar)
  2.    @use (ocl-file-delchar)
  3.    ;OCL{{{}}}
  4.    ;OCL{{{  reference description
  5.    @if-using ( FUN-REFERENCE ) ; 1 ;
  6.    Libary, simulating some functions, deleted from Origami C-source.
  7.    @fi
  8.    ;OCL}}}
  9.    ;OCL{{{  delete-character
  10.    ;OCL{{{  reference
  11.    @if-using ( FUN-REFERENCE ) ; 2 ; delete-character-ref
  12.    ;OCL{{{  @delchar-ref delete-character
  13.    Delete the character under the cursor. In overwrite  mode,  a  space
  14.    will replace the char.
  15.    ;OCL}}}
  16.    @fi
  17.    ;OCL}}}
  18.    ( defassembler delete-character
  19.       (
  20.        ;OCL{{{  test modes
  21.                 M_TEST_VIEW
  22.                 M_JMP_FALSE            start
  23.                 M_EDITING
  24.                 M_JMP_TRUE             start
  25.  
  26.                 "@                                  ; view and not in prompt,
  27.                 M_END_MACRO                         ; this will call view hook!
  28.        .start
  29.        ;OCL}}}
  30.        ;OCL{{{  join lines or delete inside
  31.                 M_LASTMES              M_ERR_PO     ; clear msg-tag
  32.                 M_END_OF_LINE
  33.                 M_JMP_FALSE            do-del       ; inside lines, delete
  34.                 M_EDITING
  35.                 M_JMP_TRUE             ready        ; do nothing in prompt
  36.  
  37.        ;OCL{{{  join lines
  38.        ;OCL{{{  try
  39.        .do-join O_DOWN
  40.                 M_SET_COUNTER          (dummy0) 1   ; try to join lines
  41.                 M_GO_COUNTER_X_POS     (dummy0)
  42.                 O_DELETE
  43.        ;OCL}}}
  44.        ;OCL{{{  check errors
  45.                 M_LASTMES              M_ERR_PO
  46.                 M_JMP_TRUE             join-line-error
  47.                 M_LASTMES              M_LONG_LINE
  48.                 M_JMP_FALSE            ready
  49.                ;M_JMP                  long-line-error
  50.  
  51.        .long-line-error
  52.                 M_PROMPT               -2 ( M_LONG_LINE ) M_END_MACRO
  53.                 M_END_MACRO
  54.  
  55.        .join-line-error
  56.                 O_UP                                ; joining lines failed
  57.                 O_END_OF_LINE
  58.                 M_JMP err
  59.        ;OCL}}}
  60.        ;OCL}}}
  61.        ;OCL{{{  delete in line
  62.        .do-del  O_RIGHT                             ; go right and do the del
  63.                 O_DELETE
  64.                 M_LASTMES              M_ERR_PO
  65.                 M_JMP_FALSE            ready
  66.                ;M_JMP                  in-line-error
  67.        ;OCL}}}
  68.        ;OCL{{{  handle error
  69.        .in-line-error
  70.                 O_LEFT                              ; go back and report error
  71.  
  72.        .err     M_PUSH_INT             modify-behaviour
  73.                 M_SET_COUNTER          modify-behaviour 2
  74.                 M_PROMPT               -2 ( M_ERR_PO ) M_END_MACRO
  75.                 M_POP_INT              modify-behaviour
  76.        ;OCL}}}
  77.        ;OCL}}}
  78.        .ready
  79.       )
  80.    )
  81.    ;OCL}}}
  82.    ;OCL{{{  delete-to-end-of-line
  83.    ;OCL{{{  reference
  84.    @if-using ( FUN-REFERENCE ) ; 2 ; delete-to-end-of-line-ref
  85.    ;OCL{{{  delete-to-end-of-line
  86.    Delete all characters from current position  to  end  of  line.  The
  87.    deleted  text  is moved  to the delete-buffer. If the cursor  is  in
  88.    front of a closed fold, the complete fold will be removed.
  89.    If OCL variable modify-behaviour is set to not null, the  text  will
  90.    be killed, instead of deleted.
  91.    ;OCL}}}
  92.    @fi
  93.    ;OCL}}}
  94.    ( defvar ( dtoeol-x ) )
  95.    ( deffun delete-to-end-of-line
  96.       ( if in-prompt
  97.          ;OCL{{{  simply delete all chars
  98.          ( while not(test-end-line)
  99.             ( forward-character
  100.               delete-previous-character
  101.             )
  102.          )
  103.          ;OCL}}}
  104.         else
  105.          ;OCL{{{  try to open line, to delete rest with delete-line!
  106.          ( set dtoeol-x store-pos
  107.            case
  108.             ;OCL{{{  closed fold and in front of line -> move directly to {{
  109.             ( or(test-fold-line test-filed)
  110.                ( beginning-of-line
  111.                  if <(store-pos dtoeol-x) ( goto dtoeol-x ) fi
  112.                )
  113.             )
  114.             ;OCL}}}
  115.             ;OCL{{{  begin/end fold and in front of {{ -> crash
  116.             ( or(test-begin-fold test-end-fold)
  117.                ( beginning-of-line
  118.                  if >=(store-pos dtoeol-x)
  119.                   ( goto dtoeol-x "$ return-from-macro )
  120.                  else
  121.                   ( goto dtoeol-x )
  122.                  fi
  123.                )
  124.             )
  125.             ;OCL}}}
  126.            esac
  127.            ;OCL{{{  splitt line and delete second part
  128.            if last-message M_ERR_PO () fi
  129.            newline-and-indent
  130.            if and(not(test-view) not(last-message M_ERR_PO))
  131.             ( if modify-behaviour ( kill-line ) else ( delete-line ) fi
  132.               previous-line
  133.               goto dtoeol-x
  134.             )
  135.            fi
  136.            ;OCL}}}
  137.          )
  138.          ;OCL}}}
  139.         fi
  140.       )
  141.    )
  142.    ( undeclare ( dtoeol-x ) )
  143.    ;OCL}}}
  144. @fi
  145.